//
//  RulesViewController.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/8/28.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "RulesViewController.h"
#import "RulesTableViewCell.h"

@interface RulesViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, weak)UIImageView * backViewImage;
@property (nonatomic, strong)UITableView * tableView;
@property (nonatomic, weak)UILabel * titleLabel;
@property (nonatomic, weak)UILabel * subLabel;


@end

@implementation RulesViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //《"风险披露书"》
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupNavBar];
    
    [self setupUI];
    
}

- (void)setupNavBar{
    
    self.title = @"《“风险披露书”》";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"1返回"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToLogView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}


- (void)setupUI{
    
    UIImageView * backImage = [[UIImageView alloc] init];
    
    backImage.image = [UIImage imageNamed:@"背景"];
    
    self.backViewImage = backImage;
    
    [self.view addSubview:self.backViewImage];
    
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.text = @"DCM关于风险披露的特别约定条款";
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    
    self.titleLabel = titleLabel;
    
    [self.view addSubview:self.titleLabel];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 110 * SCREENH6, SCREEN_WIDTH, SCREENH_HEIGHT - 110 * SCREENH6)];
    
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.bounces = NO;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    [self.tableView registerClass:[RulesTableViewCell class] forCellReuseIdentifier:@"RulesCell"];
    
    [self.view addSubview:self.tableView];
    
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    RulesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RulesCell" forIndexPath:indexPath];
    
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return SCREENH_HEIGHT + 1000 * SCREENH6;
}


//- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return 10;
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return UITableViewAutomaticDimension;
//}


- (void)viewDidLayoutSubviews{
    
    [self.backViewImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.bottom.mas_equalTo(self.view);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(80 * SCREENH6);
    }];
    
    [self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.view).offset(15 * SCREENH6);
        make.trailing.mas_equalTo(self.view).offset(-15 * SCREENH6);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10 * SCREENH6);
    }];
}


- (void)backToLogView{
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
